package com.hand.springcloud.controller;


import com.hand.springcloud.entities.Product;
import com.hand.springcloud.service.ProductClientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.List;

/**
 * @ Description   :  控制层-消费者
 * @ Author        :  xiong.yilin@hand-china.com
 * @ CreateDate    :  2019/9/6 17:13
 */
@RestController
public class ProductController_Feign {

    // 向 ProductController_Feign 注入 ProductClientService 对象
    @Autowired
    private ProductClientService service;

    @RequestMapping(value = "/consumer/product/add")
    public boolean add(Product product){
        return service.add(product);
    }

    // @FeignClient接口方法有基本类型参数在参数必须加@PathVariable("XXX") 或 @RequestParam("XXX")
    @RequestMapping(value = "/consumer/product/get/{id}")
    public Product get(@PathVariable("id") Long id){
        return service.get(id);
    }

    @RequestMapping(value = "/consumer/product/list")
    public List<Product> list(){
        return service.list();
    }
}
